<template>
	<view class="body">
		<xk-header title="巡检详情"></xk-header>
		<view class="list" >
			<view class="list-item header" @click="more = !more">
				<view>巡检单号:  {{data.inspece_no}}</view>
				<image v-if="!more" src="/static/up.png"></image>
				<image v-else  src="/static/down.png"></image>
			</view>
			<view v-if="more" class="data-item">
				<view class="order-info">
					<view class="info-item"><view class="key">设备信息：</view>{{data.device_code}}-{{data.device_name}}</view>
					<view class="info-item"><view class="key">巡检位置：</view>-</view>
					<view class="info-item"><view class="key">巡检时段：</view>{{data.plan_start_time}} - {{data.plan_end_time}}</view>
				</view>
			</view>
		</view>

		<view v-if="data.status > '20'" class="list" >
			<view class="list-item header" @click="orderMore = !orderMore">
				<view>巡检记录</view>
				<image v-if="!orderMore" src="/static/up.png"></image>
				<image v-else  src="/static/down.png"></image>
			</view>
			<view v-if="orderMore" class="data-item">
				<view class="order-info">
					<view class="info-item"><view class="key">巡检人：</view>{{data.record_user_name}}</view>
					<view @click="viewDetail" class="info-item" style="justify-content: space-between;">
						<view class="key">巡检详情：</view>
						<view style="display: flex; align-items: center;">
							<text class="right-title1" style="color: #2C72FF;">查看明细</text>
							<image mode="aspectFill" class="jiantou" src="/static/jiantou.png"/>
						</view>
					</view>
					<view class="info-item"><view class="key">巡检结果：</view>{{resultMap[data.patrol_result]}}</view>
					<view class="info-item"><view class="key">完成时间：</view>{{data.finish_time | formatDateMin}}</view>
					<view class="info-item"><view class="key">是否超时：</view>{{data.is_timeout == '1' ? '是' : '否'}}</view>
					<view v-if="data.abnormal_content" class="info-item"><view class="key">异常描述：</view><text>{{data.abnormal_content}}</text></view>
					<view v-if="data.patrol_image" class="info-item"><view class="key"></view>
						<image-list :pics="data.patrol_image"></image-list>
					</view>

					<view v-if="data.check_user_name" class="info-item"><view class="key">抽查人：</view><text>{{data.check_user_name}}</text></view>
					<view v-if="data.check_result" class="info-item"><view class="key">抽查结果：</view><text>{{data.check_result == '10' ? '合格' : '不合格'}}</text></view>
					<view v-if="data.check_remark" class="info-item"><view class="key">抽查意见：</view><text>{{data.check_remark}}</text></view>
				</view>
			</view>
		</view>
		<view class="common-bottom-view">
			<view class="common-btn" @click="back">返回</view>
		</view>
		<view class="common-zw"></view>


	</view>
</template>

<script>
	import moment from 'moment'
	export default {
		data() {
			return {
				inspeceId: '',
				data: {},
				resultMap: {},
				more: true,
				orderMore: true,
			};
		},
		onLoad(options) {
			this.inspeceId = options.inspeceId
			this.getData();
		},
		methods:{
			getData(){
				this.$api.baseData_getToolDataList({code: 'PD_INSPECEL_TASK_PATROL_RESULT' + '_nostr'}).then(res =>{
					console.log('PD_INSPECEL_TASK_PATROL_RESULT=====',res)
					let resultMap = {}
					for(let item of res){
						resultMap[item.data_value] = item.data_text
					}
					this.resultMap = resultMap
				})
				this.$api.baseData_getPdInspecelTask(this.inspeceId).then((res)=>{
					this.data = res.task
				})
			},
			viewDetail(){
				uni.navigateTo({
					url: '/pages/facility-patrol/facility-patrol-result-detail?dets=' + JSON.stringify(this.data.dets)
				})
			},
			back(){
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss" scoped>
@import '@/common/from.scss';
</style>
